function initPhotoUpload(g_str_ClientID,nr)
{
	try
	{
		var _divFrame = document.getElementById('divFrame' + g_str_ClientID);
		var _divUploadMessage = document.getElementById('divUploadMessage' + g_str_ClientID);
		var _divUploadProgress = document.getElementById('divUploadProgress' + g_str_ClientID);
		var _ifrPhoto = document.getElementById('ifrPhoto' + g_str_ClientID);
		var btnUpload = _ifrPhoto.contentWindow.document.getElementById('btnUpload');
		_ifrPhoto.contentWindow.document.getElementById('txtClientID').value = g_str_ClientID;
		var uploadBool = false;
		btnUpload.onclick = function(event)
		{
			try
			{
				_divUploadMessage.style.display = 'none';
				var regExp = /^(([a-zA-Z]:)|(\\{2}\w+)\$?)(\\(\w[\w].*))(.jpg|.JPG|.jpeg|.JPEG|.gif|.GIF|.bmp|.BMP)$/;
				//var regExp = /^(([a-zA-Z]:)|(\\{2}\w+)\$?)(\\(\w[\w].*))$/;
				var nr_Array = new Array();
				var duplicate_Array = new Array();
				for (i=0;i<nr;++i)
				{
					var ph = _ifrPhoto.contentWindow.document.getElementById('File' + i.toString());
		            
					if (!regExp.test(ph.value) && ph.value.length != 0)
					{
						_divUploadMessage.innerHTML = '<span style=\"color:#ff0000\">' + _ifrPhoto.contentWindow.g_str_checkExtensions + '</span>';
						_divUploadMessage.style.display = '';
						ph.focus();
						return false;
					}
					if (ph.value.length == 0)
					{
						nr_Array[i] = "1";
					}
					if (ph.value.length != 0)
					{
						if (ArrayIndexOf(duplicate_Array, ph.value) != -1)
						{
							_divUploadMessage.innerHTML = '<span style=\"color:#ff0000\">' + _ifrPhoto.contentWindow.g_str_duplicateFile + '</span>';
							_divUploadMessage.style.display = '';
							ph.focus();
							return false;
						}
						else
							duplicate_Array.push(ph.value);
					}
				}
		        
				if(nr_Array[0] == "1")
				{
					_divUploadMessage.innerHTML = '<span style=\"color:#ff0000\">' + _ifrPhoto.contentWindow.g_str_checkEmpty + '</span>';
					_divUploadMessage.style.display = '';
					ph.focus();
					return false;
				}
				
				_ifrPhoto.contentWindow.document.getElementById('photoUpload').submit();
				_divFrame.style.display = 'none';
				_divUploadProgress.style.display = '';
			}
			catch(err)
			{
				_divUploadMessage.innerHTML = '<span style=\"color:#ff0000\">' + _ifrPhoto.contentWindow.g_str_checkPathFile + '</span>';
				_divUploadMessage.style.display = '';
				ph.focus();
			}
		}
	}
	catch(err)
	{
		window.location = window.location + "&err=size";
	}
}

function ArrayIndexOf(a, x)
{
	if (a == null)
		return -1;
	for (var i=0; i<a.length; ++i)
		if (a[i] == x)
			return i;
	return -1;
}

function showUploadProgress(message,g_str_ClientID,bError)
{
	var color = '#008000';
	var _divUploadMessage = document.getElementById('divUploadMessage' + g_str_ClientID);
	var _divFrame = document.getElementById('divFrame' + g_str_ClientID);
	var _divUploadProgress = document.getElementById('divUploadProgress' + g_str_ClientID);
	_divFrame.style.display = '';
	_divUploadProgress.style.display = 'none';
	_divUploadMessage.innerHTML = '<span style=\"color:' + color + '\;font-weight:bold">' + message + '</span>';
	_divUploadMessage.style.display = '';
	window.parent.window.opener.$get(window.parent.window.opener.g_str_btnUpload).click();
}

function reset2()
{
	var str_ClientID = document.getElementById('txtClientID').value;
	var _divUploadMessage = window.parent.document.getElementById('divUploadMessage' + str_ClientID);
	_divUploadMessage.style.display = 'none';
	var _lblError = document.getElementById('lblError');
	_lblError.style.display = 'none';

	document.all['photoUpload'].reset();
	document.getElementById('txtClientID').value = str_ClientID;
}
